<?php
function render_item_anime($data,$type=1){
	
	if($_SESSION['mobile']!=0){
	//	render_item_truyen_mobi($data,$type);
	}else
	if($data){?>

    <?php
	$num=count($data);
	$rows=ceil($num/6);
		for($i=0;$i<$rows;$i++){
				$j=$i*6;
				$dt=array_slice($data,$j,6);
				
				?>
                
                <div class="row" style="margin-top:10px; margin-bottom:10px">
                	<?php
					foreach($dt as $row){
					?>
						<div class="col-md-2 col-sm-3 col-xs-6 each-normal-item">
                    		<div class="item_anime_box" title="<?php echo $row['name']; ?>" >
	                        	<div class="img" style="text-align:center; position:relative">
	                                                           
                                 
                                	<a href="<?php echo url_anime($row['id'],$row['alias']) ?>"><img class="lazy img-responsive" data-original="<?php echo gglink($row['hinhanh'])?>" style="margin:auto ; width:140px; height:180px"   /></a>
                                </div>
                                <div class="item_bottom">
                                	<div class="title"><a href="<?php echo url_anime($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></div>
                                    <div class="title2"><a href="<?php echo $row['ep_moinhaturl']; ?>"><?php echo $row['ep_moinhat']; ?></a></div>
                                </div>
                        	</div><!-- End item_truyen_box -->
                    	</div> <!-- End of col-md-3 -->
					
					<?php	
					}
					?>
                </div>
                <?php
		
		}
?>
	
<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---

function render_item_anime_slide($data,$type=1){
	
	if($_SESSION['mobile']!=0){
	//	render_item_truyen_mobi($data,$type);
	}else
	if($data){?>

    <?php
	$num=count($data);
	$rows=ceil($num/6);
		$str="";
		for($i=0;$i<$rows;$i++){
				$j=$i*6;
				$dt=array_slice($data,$j,6);
				
				
                
                $str.='<div class="row" style="margin-top:10px; margin-bottom:10px">';
                		
						foreach($dt as $row){
									
                       $str.='<div class="col-md-2 col-sm-3 col-xs-6">';
                    	  $str.='<div class="item_anime_box">';
                                     $str.=' <div class="img" style="text-align:center; position:relative">';
                              
                                	 $str.='<a href="'.url_anime($row['id'],$row['alias']).'"><img class="lazy img-responsive" src="'.gglink($row['hinhanh']).'" style="margin:auto; width:140px; height:180px"   /></a>';
									    $str.='</div>';
                                 $str.='<div class="item_bottom">';
                                    $str.='<div class="title"><a href="'.url_anime($row['id'],$row['alias']).'">'.$row['name'].'</a></div>';
									 $str.='<div class="title2"><a href="'.$row['ep_moinhaturl'].'">'.$row['ep_moinhat'].'</a></div>';
                               $str.=' </div>';
                       $str.=' </div><!-- End item_truyen_box -->';
                   $str.=' </div> <!-- End of col-md-3 -->';
					
						}
						
               $str.=' </div>';
                
		
		}
		 return $str;
?>
	
<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---

function render_item_anime2($data,$type){

	if($data){
	$num=count($data);
	$rows=ceil($num/2);
		for($i=0;$i<$rows;$i++){
				$j=$i*2;
				$dt=array_slice($data,$j,2);
				
			
				?>
                
                <div class="row <?php echo "row".$i%2 ?>" >
                		<?php
						foreach($dt as $row){
						
							?>
                	<div class="col-md-6">
                    	<div class="item2">
                  
                       
                        	<div class="item2_img pull-left" >
                            	<?php if($row['tinhtrang']==1){ echo '<span class="badge_status">'.$row['tinhtrang-text'].'</span>';}?>
                              
                           <img class="lazy img-responsive" data-original="<?php echo gglink($row['hinhanh'])?>" style="margin:auto; width:75px; height:110px"   />
                           </div>
                            <div class="item2_data" style="display:table-cell;">
                            		<div class="title"><a href="<?php echo url_anime($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></div>
                                 	<!--  <div class="show-truyen-rating"  data-average="<?php echo $row['rate_average']; ?>"></div> -->
                                    <div class="item2_theloai " style="padding-top:10px"><?php echo $row['theloai2']['2']; ?></div>
                              
                                     <div class="item2_ep"> <a href="<?php echo $row['ep_moinhaturl'] ?>"><?php echo $row['ep_moinhat']; ?></a> &nbsp;&nbsp;
                                     <?php echo time_ago($row['ep_ngaythem']); ?>
                                     </div>
                                      <div class="item2_ep"> <i class="fa fa-eye"></i> <?php echo $row['views'] ?> views                          
                                     </div> 
									
                                
                                   
                                    

                            </div>
                            <div class="clearfix"></div>
                        </div> <!-- End of item2 -->
                    </div><!-- End col md 6 -->
                 
					
					<?php	}
						?>
                </div>
                <?php
		
		}
?>
	
<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---


function render_tag2_anime($data){
		if($data['anime']){
			$row=$data['anime'];
	?>              
                <div class="row" style="background-color:#FFF" >
                	 <div class="col-md-6">
                    	<h4>Kết Qủa Tìm Kiếm Từ Khóa </h4>
                    	
                        <div class="list-group">
                        <?php 
						if($data['ep']){
							
							
						
							if(!$data['ep'][0]){
								$r1=$data['ep'];
					
								echo"	 <a href='".url_anime_episode($r1['id'],$r1['seourl'],$row['alias'])."' class='list-group-item'><b>".$r1['ten']."</b><span class='pull-right'>".time_ago($r1['ngaythem'])."</span> </a>";
							}else{
							  foreach($data['ep'] as $r1){
							  
							  	echo"	 <a href='".url_anime_episode($r1['id'],$r1['seourl'],$row['alias'])."' class='list-group-item'><b>".$r1['ten']."</b><span class='pull-right'>".time_ago($r1['ngaythem'])."</span> </a>";
							  }
							}
						}
						?>
                         
						</div>
                        
                    </div>
                	<div class="col-md-6">
                    	<div class="item2">
                  
                      
                        	<div class="item2_img pull-left" >
                            	<?php if($row['tinhtrang']==1){ echo '<span class="badge_status">'.$row['tinhtrang-text'].'</span>';}?>
                           
                           <img class="lazy img-responsive" data-original="<?php echo gglink($row['hinhanh'])?>" style="margin:auto; width:75px; height:110px"   />
                           </div>
                            <div class="item2_data">
                            		<h2><a href="<?php echo url_anime($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></h2>
                                 
                                    <div class="item2_theloai"><?php echo $row['theloai2']['2']; ?></div>
                                    
                              
                                     <div class="item2_ep"> <a href="<?php echo $row['ep_moinhaturl'] ?>"><?php echo $row['ep_moinhat']; ?></a> &nbsp;&nbsp;
                                     <?php echo time_ago($row['ep_ngaythem']); ?>
                                     </div>
                                      <div class="item2_ep"><i class="fa fa-heart"></i> <?php echo $row['thanks'] ?> &nbsp;&nbsp; <i class="fa fa-eye"></i> <?php echo $row['views'] ?>                           
                                     </div>
                                
                            </div>
                            <div class="clearfix"></div>
                            
                            <div style="color:#999; font-size:11px"><?php echo short_str($row['noidung'],300) ?></div>
                        </div> <!-- End of item2 -->
                    </div><!-- End col md 6 -->
                   
                 
					
					
                </div>
                <?php
		}else//
		{
			echo "<h1 class='alert alert-warning'>Không có kết quả nào được tìm thấy</h1>";
		}

} //End render item tryen ---


function render_tag_anime($data){
		if($data['anime']){
			$row=$data['anime'];
	?>              
                <div class="row" style="background-color:#FFF" >
                	
                	<div class="col-md-6">
                    	<div class="item2">
                  
                         <div class="badge_ep"><?php echo $row['item_ep_max']." / ".$row['tongsoep']; ?></div>
                        	<div class="item2_img pull-left" >
                            	<?php if($row['tinhtrang']==1){ echo '<span class="badge_status">'.$row['tinhtrang-text'].'</span>';}?>
                               <?php if($row['new']==1){echo ' <div class="ribbon ribbon_new"></div>';}?>
                               <?php if($row['pick']==1){echo ' <div class="ribbon ribbon_hot"></div>';}?>
                           <img class="lazy img-responsive" data-original="<?php echo gglink($row['hinhanh'])?>" style="margin:auto"   />
                           </div>
                            <div class="item2_data pull-left">
                            		<h2><a href="<?php echo url_anime($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></h2>
                                 
                                    <div class="item2_theloai"><?php echo $row['theloai2']['2']; ?></div>
                                    <?php if($row['item_ep']){
										echo '  <div class="item2_ep"><a href="'.$row['item_ep']['url'].'">';
										echo $row['item_ep']['title'];
										echo '</a>';
										echo ' <span class="item2_time" >'.time_ago($row['item_ep']['time_update']).'</span>';
										echo '</div>';
									}?>
                                
                                    <div class="item2_fansub"><i class="fa fa-comment"></i><?php echo $row['comments']; ?>  &nbsp;&nbsp;<i class="fa fa-eye"></i> <?php echo $row['views']; ?> </div>
                            </div>
                            <div class="clearfix"></div>
                            
                            <div style="color:#999; font-size:11px"><?php echo $row['gioithieu'] ?></div>
                        </div> <!-- End of item2 -->
                    </div><!-- End col md 6 -->
                    <div class="col-md-6">
                    	<h4>Episode Mới Nhất của anime <b><?php echo $data['anime']['name'] ?></b> </h4>
                    	
                        <div class="list-group">
                        <?php 
						if($data['ep'])
						foreach($data['ep'] as $r1){
						echo"	 <a href='".$r1['ep']['url']."' class='list-group-item'><b>[".$r1['fansub']['name']."]</b> ".$row['name']." ".$r1['ep']['title']." </a>";
						}?>
                         
						</div>
                        
                    </div>
                 
					
					
                </div>
                <?php
		}else//
		{
			echo "<h1 class='alert alert-warning'>Không có kết quả nào được tìm thấy</h1>";
		}

} //End render item tryen ---
function render_item_anime_mobi($data,$type){

	if($data){
			
	
				
				?>
			
                <ul class="list-group truyen_mobi_list">
                		<?php
						$i=1;
						foreach($data as $row){
							$j=$i%2;
							?>
							
                          
                      <li class="list-group-item mobi_item mobi_item<?php echo $j;?>">
                        		
                            
                                	<a href="<?php echo url_anime($row['id'],$row['alias']) ?>">
                                    <div class="img pull-left">
                                    <img class="lazy img-responsive" src="<?php  echo HOME ?>public/images/loading11.gif" data-original="<?php echo TRUYEN_IMAGE_LOCAL.$row['hinhanh']?>"  />
                                    </div></a>
                      			
                              <div style="display:table-cell">
                                <div class="title"><a href="<?php echo url_anime($row['id'],$row['alias']) ?>"><?php echo $row['ten']; ?></a></div>
                                <div style="height:3px"></div>
                                <div class="chuong_name">
                                <?php if($row['tinhtrang']!=1){ ?>
                                <a href="<?php echo $row['chuongmoinhat_url']?>"><?php echo short_str($row['chuongmoinhat'],25)?></a>
                                <?php }else{ echo "Hoàn Thành  -  ".$row['sochuong']." chương"; }?>
                            
                                </div>
                                <div>
                                     <span class="chuong_name">
                                     <?php echo "<span style='color:#3498db;font-size:12px'>".$row['tacgia']."</span>"; ?>
                                     </span>
                                    &nbsp; &nbsp;
                                      <span class="tags"><i class="fa fa-tags"></i> <?php echo $row['theloai2']['2'];?> </span>
                                </div>
                                <div class="stat_info">
                                	
                                     <span style="color:#999; font-size:12px"><?php echo $row['views']; ?> Views </span>   &nbsp; &nbsp; <?php echo time_ago($row['time_update']); ?>
                            
                                </div>
                                </div>
                              
                              
                            <div class="clearfix"></div>
                        </li><!-- End item_li -->
                   
					
					<?php	
					$i++;
					}
						?>
               </ul>
                <?php
		
		
?>

<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---

function render_item_video_home($data){

	if($data){
		$num=count($data);
		$rows=ceil($num/3);
		for($i=0;$i<$rows;$i++){
			$j=$i*3;
			$dt=array_slice($data,$j,3);
			?>
                <div class="row">
                		<?php
						foreach($dt as $row){?>
							
                                           <div class="col-md-4" id="home_video_box">
                                        <div class="item_video_box">
                                           
                                            <div class="wrap_bottom_item">
                                            <div class="title"><a href="<?php echo url_post($row['pid'],$row['alias'],'video'); ?>"><?php echo $row['title']; ?></a> </div>
                                            <div class="img" style="float:left"><a href="<?php echo url_post($row['pid'],$row['alias'],'video'); ?>"><img class="lazy img-responsive" data-original="<?php echo $row['image']; ?>" /></a></div> 
                                             
                                            <div class="stat_info">
                                            <div class="author" style="margin-bottom: 3px;"><a href="<?php echo url_video_user($row['username']); ?>"><?php echo $row['username']; ?></a></div>
                                             <div class="tags" ><i class="fa fa-tags"></i><?php echo $row['category']; ?></div>
                                                    <span class="view"><?php echo $row['views']; ?> lượt xem</span> <br />
                                                    <span class="time">
													<?php echo time_ago($row['date_created']); ?>
                                                    </span>
                                                        <div class="clearfix"></div>
                                            </div>
                                            </div>
                                        </div> <!-- End of video item box -->
                                        </div> <!-- End of col-md-3 -->
					
					<?php	}
						?>
                </div>
                <?php
		
		}
?>

<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End video render


function render_item_blog_home($data){

	if($data){
		$num=count($data);
		$items=ceil($num/3);
		for($i=0;$i<3;$i++){
			if($i==0){
				$dt=array_slice($data,0,$items);
			}else{
				$dt=array_slice($data,$i*2,2);
			}
			?>
                <div class="col-md-4 home_blog_box">
                		<?php
						foreach($dt as $row){?>
					<div class="item_blog_box" >
				  <div class="title"><a href="<?php echo url_post($row['pid'],$row['alias'],'blog'); ?>"><?php echo $row['title']; ?></a></div>
                   
                   <div class="clearfix"></div>
      <div class="img"><a href="<?php echo url_post($row['pid'],$row['alias'],'blog'); ?>"><img class="lazy img-responsive" data-original="<?php echo $row['image']; ?>" /></a></div>
       <div class="stat_info">
                    	<span class="author pull-left"><a href="<?php echo url_blog_user($row['username']); ?>"><i class="fa fa-user"></i> <?php echo $row['username']; ?></a></span>
                        
                        <span class="view pull-right"><?php echo $row['views']; ?> lượt xem</span>
                        
                        <div class="clearfix"></div>
                   </div>
      <div class="noidung">
  	    <?php echo cutstring($row['sdes'],120); ?>
  	    
         </div>
     <p class="textmore pull-right"><a href="<?php echo url_post($row['pid'],$row['alias'],'blog'); ?>"><span class="label panel-label-small-title">Xem Thêm &rarr;</span></a></p>
            <div class="clearfix"></div>
            </div><!-- End of itemblogbox -->
					
					<?php	}
						?>
                </div>
                <?php
		
		}
?>

<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} // End render blog item

function render_fansub_ep($data,$alias){
/*	echo "<pre>";
	print_r($data);
	echo "</pre>";*/
	//Chu y fansub_id== 3 / tuc la fansub_id cua Fansub_tong Hop - viet tat cua anime47 playlist
	//render head tab
	?>
   
    <?php
	 $str= '<ul class="nav nav-tabs" id="truyen_detail">';
	
	  $j=1; if($data)
	  foreach($data as $fs){
		  
		  
		  if($j==1){
		  $str.=' <li class="active" id="'.$fs['fansub_id'].'"><a href="#fansub'.$fs['fansub_id'].'" data-toggle="tab" >'.$fs['name'].'</a></li>';
		  }else{
			 $str.=' <li id="'.$fs['fansub_id'].'"><a href="#fansub'.$fs['fansub_id'].'" data-toggle="tab" >'.$fs['name'].'</a></li>';
		  }
		  $j++;
	  }
	 $str.= '</ul>';
	 
	//Render tab detail
	
   $str.=' <div class="tab-content fansub_ep">';

	$j=1;
		foreach ($data as $fs){
			if($j==1){
			 $str.= ' <div class="tab-pane fade in active" id="fansub'.$fs['fansub_id'].'">';
			 
			  $str.='<div><ul class="fansub_info pull-right">';
			  	
				if($fs['trangchu'] !=''){
					$str.='<li><a href="'.$fs['trangchu'].'" ref="nofollow" ><span class="info"><i class="fa fa-home"></i> Trang chủ</span></a></li>';
				}
				 if($fs['facebook'] !=''){
					$str.='<li><a href="'.$fs['facebook'].'" ref="nofollow" ><span class="info"><i class="fa fa-facebook"></i> Facebook</span></a></li>';
				}		
			   $str.='</ul></div>';
			   $str.='<div class="clearfix"></div>';
			   if($fs['gioithieu']!=''){
				  $str.='<div>'.$fs['gioithieu'].'</div>';
			   }
			   
			   
			  
						  $str.=  '<ul class="nav nav-pills">';
						  	if($fs['ep'])
								foreach($fs['ep'] as $r1){
									 $str.=  "<li id='ep".$r1['id']."'><a href='".url_anime_episode($r1['id'],$r1['alias'],$alias)."'>".$r1['name']."</a></li>";	
								}
						  $str.=  '</ul>';
				
			 $str.=  '	</div>';
			}else{ //start esle j=1 , Ko co class active thoi -------------------
					 $str.=  ' <div class="tab-pane fade in" id="fansub'.$fs['fansub_id'].'">';
					  $str.='<div><ul class="fansub_info pull-right">';
					 
				if($fs['trangchu'] !=''){
					$str.='<li><a href="'.$fs['trangchu'].'" ref="nofollow" target="_blank"><span class="info"><i class="fa fa-home"></i> Trang Chủ</span></a></li>';
				}
				 if($fs['facebook'] !=''){
					$str.='<li><a href="'.$fs['facebook'].'" ref="nofollow" target="_blank" ><span class="info"><i class="fa fa-facebook"></i>&nbsp; Facebook</span></a></li>';
				}		
			   $str.='</ul></div>';
			   $str.='<div class="clearfix"></div>';
			   if($fs['gioithieu']!=''){
			   $str.='<div>'.$fs['gioithieu'].'</div>';
			   }
					 
					 //Anime 
				
							 $str.=  '<ul class="nav nav-pills">';
							 	if($fs['ep'])
									foreach($fs['ep'] as $r1){
										 $str.=  "<li id='ep".$r1['id']."'><a href='".url_anime_episode($r1['id'],$r1['alias'],$alias)."'>".$r1['name']."</a></li>";	
									}
							 $str.=  '</ul>';
		
					  $str.=  '	</div>';
				 }
			 $j++;
		} // End of  foreach tab content
		 
 
	 $str.= '</div>';
	 
	 return $str;
    
} //end of function render fansub_ep

function render_anime_box($data){
?>
   <div class="row" itemscope itemtype="http://schema.org/book"> <!-- Start anime info box -->
             
            		<div class="col-md-3 col-sm-3 col-xs-12">
                    	<div class="item_truyen_box" style="text-align:center">
                        		   <?php if($_SESSION['mobile']!=0){?>
                                    <h1 class="name" itemprop='name'><span style="line-height:30px"><?php echo $data['name'] ?></span></h1>
									<?php }?>
                                <div class="img">
                                	  <a itemprop="url" href="<?php echo url_anime($data['id'],$data['alias']) ?>"><img itemprop='image' src="<?php echo gglink($data['hinhanh']) ?>" class="img-rounded img-responsive" /></a>
                                </div>
                                        <div id="wrap-rating" class="rating" xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate">
                                	<h3 style="font-size: 12px; line-height: 18px;" property="v:itemreviewed"><?php echo $data['name'] ?></h3>
                                	<div id="truyen-rating" style="margin: 0px auto;" class="basic" data-average="<?= $data['rate_average']; ?>" data-id="1"></div>
                                	
					   				<span rel="v:rating">
						   				<p id="rating-point" typeof="v:Rating">
						   					<span property="v:average"><?= $data['rate_average']; ?></span> / 
	         								<span property="v:best">5</span> 
	         								<p><span property="v:count"><?= $data['rate_count'] ?></span> lượt đánh giá</p>
	         							</p>
	         							
	         						</span>
         							<p style="display: none; margin-top: 3px;" id="rate_message"></p>
         							
         							
					   				
                                </div>
								<!-- JS to add -->
								<script type="text/javascript">
								  $(document).ready(function(){
									rateDisable = false;
									if($.cookie('ranime_<?php echo $data['id']; ?>') == '1'){
					
										rateDisable = true;
									}
									  
									$(".basic").jRating({
										bigStarsPath : '<?php echo HOME ?>public/images/stars.png', // path of the icon stars.png
										smallStarsPath : '<?php echo HOME ?>public/images/small.png', // path of the icon small.png
										type:"big",
										length : 5,
										decimalLength : 1,
										isDisabled: rateDisable,
										step: true,
										nbRates : 3,
										rateMax : 5,
										showRateInfo:false,
										phpPath : '<?= HOME; ?>index.php?module=ajax&act=ajax&rating=1&act=anime&id=<?= $data['id']; ?>',
										
										onSuccess : function(data){
											
											if(data){
												if(data.type == 'success'){
													classMsgRating = 'rate_success';
													$.cookie('ranime_<?php echo $data['id']; ?>', '1', { expires: 30 });
												}else if(data.type == 'error'){
													classMsgRating = 'rate_error';
												}
												
												$('#rate_message').html('<p class="'+classMsgRating+'">'+data.message+'</p>');
												$('#rate_message').slideDown('normal').delay(3000).slideUp('normal');
											}
											
										  },

										
									});
								  });
								</script>

                                  <div class="btn-group-vertical" >
      
        <a class="btn btn-info btn-sm follow-story" role="button">Theo Dõi Manga  Này  </a>	
       
        
        </div>
                              	
                        </div><!-- End item_truyen_box -->
                    </div> <!-- End of col-md-3 -->
                      
                    <div class="col-md-9 col-sm-9 col-xs-12">
                     <?php if($_SESSION['mobile']==0){?> <h1 class="name" itemprop='name'><?php echo $data['name'] ?></h1><?php }?>
                                                                      

                    <div class="item_truyen_detail" style="background-color:#fafafa; border-radius:5px; margin-top:10px">
                   

<ul class="nav nav-tabs" id="truyen_detail">
  <li class="active"><a href="#truyen_thongtin" data-toggle="tab" >Thông Tin</a></li>
 
  <li><a href="#truyen_tags" data-toggle="tab"> Tags</a></li>


</ul>

<div class="tab-content truyen_thongtin_tab" style="background:#fff">
  <div class="tab-pane fade in active" id="truyen_thongtin">
  <table class="table" id="truyen_detail_metadata">
                    		<tr>
                    			<td class="theloai" width="120" align="left">Thể Loại:</td>
                    			<td class="theloai"><?php echo $data['theloai2']['2']; ?></td>
                    		</tr>
                            <tr>
                    			<td class="theloai" width="120" align="left">Tác giả :</td>
                    			<td class="theloai"><?php echo $data['tacgia']; ?></td>
                    		</tr>
                    		<tr>
                    			<td class="tinhtrang" align="left">Tình Trạng:</td>
                    			<td class="tinhtrang"><span><?php echo $data['tinhtrang-text']; ?></span></td>
                    		</tr>
                            <tr>
                    			<td class="tinhtrang" align="left">Nguồn</td>
                    			<td class="nguon"><span><?php if($data['nguon']!=''){ echo $data['nguon'];}else{ echo "Đang cập nhật ...";} ?></span></td>
                    		</tr>
                    		<tr>
                    			<td class="view" align="left">Lượt Xem:</td>
                    			<td class="view"><span class="badge"><?php echo $data['views']; ?></span></td>
                    		</tr>
                            <tr>
                    			<td class="view" align="left">Ngày Đăng:</td>
                    			<td class="view"><span class="badge"><?php echo time_ago($data['upload_time']); ?></span></td>
                    		</tr>
                            
                    			
                           
                    	
                    		
                       
                    	</table>
               
  </div>
 
   					
  
       <div class="tab-pane fade" id="truyen_tags"> 
        <?php echo $data['data_tags']; ?>
         <?php echo $data['tag3']; ?>
       </div>
  
 
</div> <!-- End tab-content -->

 					<div class="noidung" itemprop='description'>
    					 <?php 
              		if($data['noidung']==''){
							$content_show = $data['gioithieu'];
							
						}else{
							$content_show = $data['noidung'];
						}
						echo $content_show;
						?>
                         
                         </div>


             </div><!-- End truyen detail-->
                    </div> <!-- End of col-md-9 -->
                   
      </div> <!-- End of  Row anime info case -->
      <input type="hidden" name="anime_id" id="anime_id" value="<?php echo $data['id']; ?>" />
<?php }
function render_anime_box2($data){
?>
   <div class="row" itemscope itemtype="http://schema.org/Book"> <!-- Start anime info box -->
             
            		<div class="col-md-12 col-xs-12">
                    	
                    <div class="row">
                    <div class="col-md-5 col-xs-5">
                    	<div class="item_truyen_box" style="text-align:center">
                        		   <?php if($_SESSION['mobile']!=0){?>
                                    <h1 class="name" itemprop='name'><span style="line-height:30px; display:none"><?php echo $data['name'] ?></span></h1>
									<?php }?>
                                <div class="img">
                                	  <a itemprop="url" href="<?php echo url_anime($data['id'],$data['alias']) ?>"><img itemprop='image' src="<?php echo TRUYEN_IMAGE_LOCAL."thumbs/".$data['hinhanh'] ?>" class="img-rounded"  /></a>
                                </div>
                                        
                        </div><!-- End item_truyen_box -->
                        
                    </div> <!-- End col-md-6 -->
                    <div class="col-md-7 col-xs-7" style="text-align:center">
                       <div id="wrap-rating" itemscope itemtype="http://data-vocabulary.org/Review">
                                	<h3 style="font-size: 12px; line-height: 18px; font-weight:bold" itemprop="itemreviewed"><?php echo $data['name'] ?></h3>
                                	<div id="truyen-rating" style="margin: 0px auto;" class="basic" data-average="<?= $data['rate_average']; ?>" data-id="1"></div>
                                	
					   				 
					   				<p id="rating-point">
					   					<span itemprop="value"><?= $data['rate_average']; ?></span> / 
         								<span itemprop="best">5</span> 
         							</p>
         							<p><?= $data['rate_count'] ?> lượt đánh giá</p>
         							<p style="display: none; margin-top: 3px;" id="rate_message"></p>
					   				
         
                                </div>
								<!-- JS to add -->
								<script type="text/javascript">
								  $(document).ready(function(){
									rateDisable = false;
									if($.cookie('ranime_<?php echo $data['id']; ?>') == '1'){
					
										rateDisable = true;
									}
									  
									$(".basic").jRating({
										bigStarsPath : '<?php echo HOME ?>public/images/stars.png', // path of the icon stars.png
										smallStarsPath : '<?php echo HOME ?>public/images/small.png', // path of the icon small.png
										type:"big",
										length : 5,
										decimalLength : 1,
										isDisabled: rateDisable,
										step: true,
										nbRates : 3,
										rateMax : 5,
										showRateInfo:false,
										phpPath : '<?= HOME; ?>index.php?module=ajax&act=ajax&rating=1&act=anime&id=<?= $data['id']; ?>',
										
										onSuccess : function(data){
											
											if(data){
												if(data.type == 'success'){
													classMsgRating = 'rate_success';
													$.cookie('ranime_<?php echo $data['id']; ?>', '1', { expires: 30 });
												}else if(data.type == 'error'){
													classMsgRating = 'rate_error';
												}
												
												$('#rate_message').html('<p class="'+classMsgRating+'">'+data.message+'</p>');
												$('#rate_message').slideDown('normal').delay(3000).slideUp('normal');
											}
											
										  },

										
									});
								  });
								</script>

                                  <div class="btn-group-vertical" ><a class="btn btn-info btn-sm follow-story" role="button">Theo Dõi Anime  Này  </a></div>
                                                    
                              
                           
                    </div> <!-- End col-md-6 -->
                    </div> <!-- End of row trong -->
                    
                        
                        
                    </div> <!-- End of col-md-12 -->
                    <div class="col-md-12 col-xs-12" style="text-align:center">

                    </div>
                      
                    <div class="col-md-12 col-sm-12 col-xs-12">
                     <?php if($_SESSION['mobile']==0){?> <h1 class="name" itemprop='name' style="display:none"><?php echo $data['name'] ?></h1><?php }?>


                    <div class="item_truyen_detail" style="background-color:#fafafa; border-radius:5px; margin-top:10px">
                   

<ul class="nav nav-tabs" id="truyen_detail">
  <li class="active"><a href="#truyen_thongtin" data-toggle="tab" >Thông Tin</a></li>
  <li><a href="#truyen_noidung" data-toggle="tab"> Nội Dung</a></li>
  <li><a href="#truyen_tags" data-toggle="tab"> Tags</a></li>


</ul>



<div style="height:5px"></div>
<div class="tab-content truyen_thongtin_tab" style="background:#fff">
  <div class="tab-pane fade in active" id="truyen_thongtin">
  <table class="table" id="truyen_detail_metadata">

                    		<tr>
                    			
                    		</tr>
                    		<tr>
                    			<td class="theloai" align="left">Thể Loại:</td>
                    			<td class="theloai"><?php echo $data['theloai2']['2']; ?></td>
                    		</tr>
                    		<tr>
                    			<td class="tinhtrang" align="left">Tình Trạng:</td>
                    			<td class="tinhtrang"><span><?php echo $data['tinhtrang-text']; ?></span></td>
                    		</tr>
                            <tr>
                    			<td class="tinhtrang" align="left">Fansub</td>
                    			<td class="nguon"><span><?php if($data['nguon']!=''){ echo $data['nguon'];}else{ echo "Đang cập nhật ...";} ?></span></td>
                    		</tr>
                    		<tr>
                    			<td class="view" align="left">Lượt Xem:</td>
                    			<td class="view"><span class="badge"><?php echo $data['views']; ?></span></td>
                    		</tr>
                    			<tr>
                    			<td class="view" align="left">Số Ep</td>
                    			<td class="sochuong"><span class="badge"><?php echo $data['item_ep_max']." / ".$data['tongsoep'];?></span></td>
                    		</tr>
                           
                    		<tr>
                    			<td class="stat_info" align="left">Đăng bởi:</td>
                    			<td class="stat_info"><span class="author"><?php echo $data['user_upload']; ?></span>  &nbsp;&nbsp;&nbsp;<span class="time"><?php echo time_ago($data['time_upload']); ?></span></td>
                    		</tr>
                    		<tr>
                    			<td class="stat_info2" align="left">Mới Nhất :</td>
                    			<td class="stat_info2">
                    				<span>
                    					<a href="<?php echo $data['item_ep']['url']; ?>"><?php echo $data['item_ep']['title']; ?></a>
                    				</span>
                    				</td>
                    		</tr>
                            <tr>
                    			<td class="stat_info2" align="left">Thời gian đăng</td>
                    			<td class="stat_info2">
                    				<span style="color:#999">
                    					<?php echo time_ago($data['upload_time']); ?>
                    				</span>
                    				</td>
                    		</tr>
                             <tr>
                    			<td class="stat_info2" align="left">Thời gian cập nhật</td>
                    			<td class="stat_info2">
                    				<span style="color:#999">
                    					<?php echo time_ago($data['update_time']); ?>
                    				</span>
                    				</td>
                    		</tr>
                    	</table>
               
  </div>
  <div class="tab-pane fade" id="truyen_noidung"> 
   					 <div class="noidung" itemprop='description'>
    					 <?php 
              		if($data['noidung']==''){
							$content_show = $data['gioithieu'];
							
						}else{
							$content_show = $data['noidung'];
						}
						echo $content_show;
						?>
                         
                         </div>
    </div>
       <div class="tab-pane fade" id="truyen_tags"> 
        <?php echo $data['ep']['data_tags']; ?>
       </div>
  
 
</div> <!-- End tab-content -->
<script>
$('#truyen_detail').click(function (e) {
  	e.preventDefault();
  	 	if($(this).find('.active').find('a').attr('href') != '#truyen_noidung'){
  		  	if($('.noidung').height() > 150){
			$('.noidung').css('height', '140').css('overflow', 'hidden');
			$('.truyen_thongtin_tab').append('<p id="threedots" style="text-align:center; font-size: 15px;">...</p><p class="viewmore extend">Xem thêm</p>');
			
		}
  }else{
	$('#threedots').remove();
	$('.viewmore').remove();
	$('.noidung').css('height', '');
  }
		  
  	$(this).tab('show');
  
});

$('.item_truyen_detail .viewmore').live('click', function(e){
	if($(this).hasClass('shorten')){
		$('.noidung').css('height', '140').css('overflow', 'hidden');
		$(this).addClass('extend');
		$(this).html('Xem thêm');
		$(this).removeClass('shorten');
		$('#threedots').html('...');
		window.scroll(0,findPos(document.getElementById("truyen_detail")) - 50);
		
	}else{
		$('.noidung').css('height', 'auto');
		$(this).addClass('shorten');
		$(this).html('Rút gọn');
		$(this).removeClass('extend');
		$('#threedots').html('');
	}
});
</script>
             </div><!-- End truyen detail-->
                    </div> <!-- End of col-md-9 -->
                   
      </div> <!-- End of  Row anime info case -->
<?php }
function render_slide($data,$alias,$max){
?>

			<div class="clearfix"></div>
            <input type="hidden" id="<?php echo $alias; ?>-slider-total-page" name="<?php echo $alias; ?>-slider-total-page" value="<?php echo $max; ?>" />
	        <input type="hidden" id="<?php echo $alias; ?>-slider-current-page" name="<?php echo $alias; ?>-slider-current-page" value="1" />
  			<a href="#" class="arrow_preview  btn-slider" style="display: block;" id="<?php echo $alias; ?>-btn-slider-prev" data-rel="<?php echo $alias; ?>"></a>
			<a href="#" class="arrow_next  btn-slider" id="<?php echo $alias; ?>-btn-slider-next" data-rel="<?php echo $alias; ?>" style="display: block;"></a>

			<div  id="<?php echo $alias; ?>-wrapper" class="slider-wrapper" data-href="1">
  			<div class="wrap-loading" id="wrap-<?php echo $alias; ?>-loading" style="display: none;">
			<div class="loading" id="<?php echo $alias; ?>-loading"><img alt="loading" src="public/images/loading11.gif"></div><br>
			</div>
  			<div id="<?php echo $alias; ?>-content-slide-1" class="<?php echo $alias; ?>-content">
             	<?php render_item_anime($data); ?>
  			</div> <!-- End of cucu content -->
            </div> <!-- End of decu wrapper -->
<?php }

 function anime_render_related($data)
 {
	 ?>
      <div class="panel panel-info  my-panel right-panel ">
 		 <div class="panel-heading">
         		<ul class="mn_nav">
            	<li><span class="head">Anime Liên Quan</span></li>
                             
            </ul>
            <div class="clearfix"></div>
         </div>
            <div class="panel-body" style="padding:0px; margin:0px">
             <div class='list-group'> 
     <?php
	 foreach($data as $row){
		 echo "<a href='".url_anime($row['id'],$row['alias'])."' class='list-group-item'>".$row['name']."<div class='clearfix'></div></a>";
	 }
 	
	 ?>
     </div> <!-- End of list group -->
       </div>
        </div>
     <?php
 }
 
 //MANGA RENDER FUNCTION
  function render_manga_update($data){
	 

 ?>
            
                  <table class="table  table_manga" style="text-align:left">
                  <?php
				  
				  foreach ($data as $row)
				   {?>
                   
                    <thead>
                <tr >
                 		
                        <th colspan="2"><div class="ngay_update"> <?php  if($row['ngay']==date('Y-m-d')){?><span class="case1"> Manga Cập Nhật Hôm Nay <?php }else{?>    
				 <span class="case2"> <?php echo time_ago($row['ngay']);?><?php }?></span>
                  	</div>
                  </th>		

                 
                
                </tr>
              </thead>
              	<tbody>
                   					<?php 
									
									foreach($row['data'] as $row){
									?>
                     <tr>
            <td>
            
            <a class="mg_name"   href="<?php echo url_anime($row['id'],$row['alias']) ?>"> <?php echo $row['name'] ?></a></td>
            <td>  <a class="mg_chapter" href="<?php echo  url_anime_episode($row['chapid'],$row['seourl'],$row['alias']) ?>"><?php  echo $row['index_show']?></a> 
                 	<?php if($row['hot']==1){?><span class="label label-danger"> HOT </span> <?php }?>
                      <?php if($row['new']==1){?><span class="label label-warning"> NEW </span> <?php }?>
                    </td>
             
          </tr>
                   					<?php } ?>
                       </tbody>             
                   
                   <?php
				   }
				   ?>
           
            </table>
            
                       
                        
                
                   <?php
 } //End of manga render update
 
   function render_manga_update2($data){
	 

 ?>
            
                  <table class="table  table_manga" style="text-align:left">
     				<?php	
						foreach($data as $row){
					?>
                     <tr>
            <td>
            
            <a class="mg_name"   href="<?php echo url_anime($row['id'],$row['alias']) ?>"> <?php echo $row['name'] ?></a></td>
            <td>  <a class="mg_chapter" href="<?php echo  url_anime_episode($row['chapid'],$row['seourl'],$row['alias']) ?>"><?php  echo $row['ten']?></a> 
                 	<?php if($row['hot']==1){?><span class="label label-danger"> HOT </span> <?php }?>
                      <?php if($row['new']==1){?><span class="label label-warning"> NEW </span> <?php }?>
                    </td>
             
          </tr>
                   					<?php } ?>
                    
           
            </table>
            
                       
                        
                
                   <?php
 } //End of manga render update
 
 
    function render_manga_update3($data){
	 

 ?>
            
                  <table class="table  table_manga" style="text-align:left">
     				<?php	
						foreach($data as $row){
					?>
                     <tr>
            <td>
            
            <a class="mg_name"   href="<?php echo url_anime($row['id'],$row['alias']) ?>"> <?php echo $row['name'] ?></a></td>
            <td>  <a class="mg_chapter" href="<?php echo $row['ep_moinhaturl']; ?>"><?php  echo $row['ep_moinhat']?></a> 
               
                    </td>
             
          </tr>
                   					<?php } ?>
                    
           
            </table>
            
                       
                        
                
                   <?php
 } //End of manga render update
 
 function render_manga_chapters($data,$alias=''){
 ?>
 	<div class="anime-pick" id="home-anime-update" style="background-color:#fafafa">
    				<span class="anime-pick-title">Danh Sách Chapter</span>
					<div class="clearfix"></div>
                    <Br/>
                    <div class="well" >
                        <select class="form-control" onchange="location.href=this.value">
                        <option>Chọn Nhanh Chap</option>
                        <?php
                          if(count($data)>0)
				 		  foreach ($data as $row)
				  		 {?>
                         <option value="<?php echo url_anime_episode($row['id'],$row['seourl']) ?>"><?php echo str_ireplace('chapter','Chap',$row['ten']) ?></option>
                          <?php }?>		
                        </select>
                        </div>
				 <table class="table  table_manga" style="text-align:left">
                   <thead>   <tr >               		
                    <th>Chapter            </th>		
					 <th class="hidden-xs">Ngày Đăng           </th>
                      <th class="hidden-xs">Views           </th>
                     
                </tr>
              </thead>
                  <?php
				   if(count($data)>0)
				   foreach ($data as $row)
				   {?>
      <tr>
      <td> <a class="mg_name"   href="<?php echo url_anime_episode($row['id'],$row['seourl']) ?>"> <?php echo str_ireplace('chapter','Chap',$row['ten']) ?></a></td>
      <td class="hidden-xs"><span>  <?php  echo time_ago($row['ngaythem'])?></span></td>
      <td class="hidden-xs"> <span> <?php  echo $row['solanxem']?></span></td>
    
     </tr>
                   				
                   
                   <?php
				   }else{
				   ?>
                   <tr>
                   	<td colspan="3"><h1 class="alert alert-warning">Đang chờ cập nhật</h1></td>
                   </tr>
           			<?php } ?>

            </table>
            	
            
		
  					
  					<div class="clearfix"></div>
  				</div>
  				
 <?php
 
 
 }
 
 //END MANGA RENDER FUNCTION
 
 //Mong render---------
   function mong_render_ngontinh($id=''){?>
	  <div class="panel panel-info my-panel right-panel">
 		 <div class="panel-heading">
    
            <ul class="nav nav-tabs mn_tab pull-left" >
            	<li><span class="head">Ngôn Tình - Tiểu Thuyết</span></li>
       
			</ul>
          
	  <div class="clearfix"></div>
         </div>
       
  		<div class="panel-body box_news">
  		<?php
       	$cache=new cache;
		$data2=$cache->load("mong_ngontinh1");
		if(!$data2){
			$data=file_get_contents('http://mong.vn/index.php?module=news&act=get&get=ngontinh');
			$data2=json_decode($data,true);
		
			$cache->save('mong_ngontinh',$data2,500);
		}
		
		
        echo "<div class='list-group'>";
			
        		foreach($data2 as $row){
				echo " <a href='".$row['url']."' class='list-group-item' >".short_str($row['title'],20)."<span class='pull-right'>".short_str($row['chuongmoinhat'],15)." </span></a>";
				$i++;
				}
        echo "</div>";
		?>
    	</div> <!-- End of body panel -->
		</div> <!-- End of panel-->

        <?php
 }

  function mong_render_truyen($id=''){?>
	  <div class="panel panel-info my-panel right-panel">
 		 <div class="panel-heading">
    
            <ul class="nav nav-tabs mn_tab pull-left" >
            	<li><span class="head">Tiên Hiệp - Kiếm Hiệp</span></li>
       
			</ul>
          
	  <div class="clearfix"></div>
         </div>
       
  		<div class="panel-body box_news">
  		<?php
      $cache=new cache;
		$data2=$cache->load("mong_truyen1");
		if(!$data2){
			$data=file_get_contents('http://mong.vn/index.php?module=news&act=get&get=truyen');
			$data2=json_decode($data,true);
		
			$cache->save('mong_truyen',$data2,500);
		}
		
		
        echo "<div class='list-group'>";
				$i=1;
        		foreach($data2 as $row){
				echo " <a href='".$row['url']."' class='list-group-item' >".$row['title']." <span class='pull-right'>".$row['chuongmoinhat']." </span></a>";
				$i++;
				}
        echo "</div>";
		?>
    	</div> <!-- End of body panel -->
		</div> <!-- End of panel-->

        <?php
 }
 
   function mong_render_blog($id=''){?>
	  <div class="panel panel-info my-panel right-panel">
 		 <div class="panel-heading">
    
            <ul class="nav nav-tabs mn_tab pull-left" >
            	<li><span class="head">Blog</span></li>
       
			</ul>
          
	  <div class="clearfix"></div>
         </div>
       
  		<div class="panel-body box_news">
  		<?php
    	$cache=new cache;
		$data2=$cache->load("mong_blog");
		if(!$data2){
			$data=file_get_contents('http://mong.vn/index.php?module=news&act=get&get=blog');
			$data2=json_decode($data,true);
		
			$cache->save('mong_blog',$data2,500);
		}
		
		
        echo "<div class='list-group'>";
				$i=1;
        		foreach($data2 as $row){
				echo " <a href='".$row['url']."' class='list-group-item' >".short_str($row['title'],40)."</a>";
				$i++;
				}
        echo "</div>";
		?>
    	</div> <!-- End of body panel -->
		</div> <!-- End of panel-->

        <?php
 }
 
  function mong_render_video($id=''){?>
	  <div class="panel panel-info my-panel right-panel">
 		 <div class="panel-heading">
    
            <ul class="nav nav-tabs mn_tab pull-left" >
            	<li><span class="head">Video</span></li>
       
			</ul>
          
	  <div class="clearfix"></div>
         </div>
       
  		<div class="panel-body box_news">
  		<?php
    	$cache=new cache;
		$data2=$cache->load("mong_video");
		if(!$data2){
			$data=file_get_contents('http://mong.vn/index.php?module=news&act=get&get=video');
			$data2=json_decode($data,true);
		
			$cache->save('mong_video',$data2,500);
		}
		
		
        echo "<div class='list-group'>";
				$i=1;
        		foreach($data2 as $row){
				echo " <a href='".$row['url']."' class='list-group-item' >".short_str($row['title'],40)."</a>";
				$i++;
				}
        echo "</div>";
		?>
    	</div> <!-- End of body panel -->
		</div> <!-- End of panel-->

        <?php
 }
 
 
 function anime24h_render(){?>
	 
  		<?php
    	$cache=new cache;
		$data2=$cache->load("anime24h");
		if(!$data2){
			$data2=file_get_contents('http://anime24h.vn/index.php?module=anime&act=remote');
			$cache->save('anime24h',$data2,500);
		}
		
		echo $data2;
 }
 //End mong render